//
//  CustomDateViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/28.
//

#import "CustomDateViewController.h"
#import "CustomDateView.h"

@interface CustomDateViewController ()

@end

@implementation CustomDateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BACKGROUNDCOLOR;
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setImage:UIImageMake(@"watch_setting") forState:UIControlStateNormal];
    rightBtn.frame = CGRectMake(0, 0, 40, 40);
    rightBtn.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    [rightBtn addTarget:self action:@selector(rightClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, kScreenWidth, kScreenHeight - NavigationContentTop)];
    scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    
    MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    root.myHorzMargin = 15;
    root.myTop = 15;
    root.myHeight = kAutoHeight;
    root.subviewVSpace = 15;
    [scrollView addSubview:root];
    
    MyLinearLayout *top = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    top.myHorzMargin = 0;
    top.padding = UIEdgeInsetsMake(15, 15, 15, 15);
    top.backgroundColor = COLOR_4;
    top.layer.cornerRadius = 15;
    top.myHeight = kAutoHeight;
    [root addSubview:top];
    
    {
        
//        self.periodLength = 24; // 24~35
//        self.menstrualPeriod = 5; // 3~8
//        self.periodStartTime = @"2022-11-15";
        
        CustomDateView *backView = [[CustomDateView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 60, kScreenWidth) periodLength:self.periodLength menstrualPeriod:self.menstrualPeriod periodStartTime:self.periodStartTime];
        backView.myHorzMargin = 0;
        backView.myHeight = kScreenWidth;
        [top addSubview:backView];
        [backView setSelectDateClick:^(NSInteger tag) {
            NSLog(@"选择的日期  %ld",tag);
        }];
        
        
        MyLinearLayout *tipsLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        tipsLay.myHorzMargin = 0;
        tipsLay.gravity = MyGravity_Vert_Center | MyGravity_Horz_Around;
        tipsLay.myHeight = 20;
        tipsLay.myTop = 30;
        [top addSubview:tipsLay];
        
        NSArray *array = @[@"月经期",@"安全期",@"排卵期",@"排卵日"];
        NSArray *imgArray = @[@"watch_yuejing",@"watch_anquan",@"watch_painuanqi",@"watch_painuanri"];
        for (int i = 0; i < array.count; i++) {
            QMUIButton * rightBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
            [rightBtn setImage:UIImageMake(imgArray[i]) forState:UIControlStateNormal];
            rightBtn.mySize = kAutoSize;
            [rightBtn setTitle:array[i] forState:UIControlStateNormal];
            [rightBtn setTitleColor:HexColor(@"#454545") forState:UIControlStateNormal];
            rightBtn.titleLabel.font = UIFontMake(13);
            rightBtn.imagePosition = QMUIButtonImagePositionLeft;
            rightBtn.spacingBetweenImageAndTitle = 5;
            [tipsLay addSubview:rightBtn];
        }
    }
    
    MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    bottom.myHorzMargin = 0;
    bottom.padding = UIEdgeInsetsMake(15, 15, 15, 15);
    bottom.backgroundColor = COLOR_4;
    bottom.layer.cornerRadius = 15;
    bottom.myHeight = kAutoHeight;
    bottom.subviewVSpace = 15;
    [root addSubview:bottom];
    
    {
        QMUIButton * rightBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
        [rightBtn setImage:UIImageMake(@"watch_painuanqi") forState:UIControlStateNormal];
        rightBtn.mySize = kAutoSize;
        [rightBtn setTitle:@"排卵期" forState:UIControlStateNormal];
        [rightBtn setTitleColor:HexColor(@"#454545") forState:UIControlStateNormal];
        rightBtn.titleLabel.font = UIFontMake(13);
        rightBtn.imagePosition = QMUIButtonImagePositionLeft;
        rightBtn.spacingBetweenImageAndTitle = 5;
        [bottom addSubview:rightBtn];
        
        [bottom addSubview:[self setAddLineTop:0]];
        
        UILabel *content = [UILabel createLabelText:@"注意月经周期的变化。正常的周期25~35天，接近排卵期时，阴道会有少许分泌物。如果经期总是拖延，甚至几个月一次，或者总是不准时，应及早就医。应该控制体重。肥胖或者过瘦都会干扰内分泌系统的协调，控制体重有助于预防和治疗排卵障碍。" font:UIFontMake(13) textColor:COLOR666];
        content.myHorzMargin = 0;
        content.myHeight = kAutoHeight;
        [bottom addSubview:content];
    }
}

- (void)rightClick {
    
}



@end
